#pragma once
#include "FWGame.h"
#include "FWTexture.h"
#include <d3dx9.h>
class FWGame;
class FWGraphic
{
protected:
	FWGame* _gameObject;
	LPD3DXSPRITE _sprite;
	D3DXMATRIX* _tranform;
	LPDIRECT3DSURFACE9 backbuffer;	
	D3DXVECTOR2 _worldPositionToViewport(D3DXVECTOR2 world,D3DXVECTOR2 center);	

public:
	FWGraphic(FWGame* fwGame);
	bool init();
	void clear(D3DCOLOR color);
	void begin();	
	void begin(D3DXMATRIX* tranform);	

	//Ve texture tai position voi width va height cua texture, su dung transform
	void tDraw(FWTexture* texture,D3DXVECTOR2 position,D3DXVECTOR2 center, D3DCOLOR color);
	//Ve texture tai destRect. su dung transform
	void tDraw(FWTexture* texture,RECT destRect,D3DXVECTOR2 center, D3DCOLOR color);
	//Ve mot phan texture tai destRect. phan nay duoc cat ra tu texture boi sourRect. su dung transform
	void tDraw(FWTexture* texture,RECT sourRect,RECT destRect,D3DXVECTOR2 center, D3DCOLOR color);					

	//Ve texture tai position voi width va height cua texture 
	void nDraw(FWTexture* texture,D3DXVECTOR2 position,D3DXVECTOR2 center, D3DCOLOR color);
	//Ve texture tai destRect 
	void nDraw(FWTexture* texture,RECT destRect,D3DXVECTOR2 center, D3DCOLOR color);
	//Ve mot phan texture tai destRect. phan nay duoc cat ra tu texture boi sourRect
	void nDraw(FWTexture* texture,RECT sourRect,RECT destRect,D3DXVECTOR2 center, D3DCOLOR color);	

	void end();	
	~FWGraphic(void);
};

